package com.cy.pj.sys.controller;

import com.cy.pj.common.pojo.JsonResult;
import com.cy.pj.sys.entity.SysDept;
import com.cy.pj.sys.service.SysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/dept")
public class SysDeptController {
    @Autowired
    private SysDeptService sysDeptService;

    @RequestMapping("/doFindObjects")
    public JsonResult doFindObjects() {
        return new JsonResult(sysDeptService.findObject());
    }

    @PostMapping("/doDeleteObject")
    public JsonResult doDeleteObject(Integer id) {
        sysDeptService.deleteObject(id);
        return new JsonResult("delete ok");
    }

    @GetMapping("/doFindZTreeNodes")
    public JsonResult doFindZTreeNodes() {
        return new JsonResult(sysDeptService.findZTreeNodes());
    }

    @PostMapping("/doSaveObject")
    public JsonResult doSaveObject(SysDept entity) {
        return new JsonResult(sysDeptService.saveObject(entity));
    }

    @PostMapping("/doUpdateObject")
    public JsonResult doUpdateObject(SysDept entity) {
        return new JsonResult(sysDeptService.updateObject(entity));
    }
}
